package com.seselin.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
import android.widget.TextView;

import com.seselin.R;

/**
 * Created by Seselin on 2018/12/13 14:49.
 */
public class PhoneInfoActivity extends Activity {

    TextView tvInfo;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple_text);

        tvInfo = findViewById(R.id.tv_text);
        setInfo();
    }

    private void setInfo() {
        DisplayMetrics dm = new DisplayMetrics();
        this.getWindowManager().getDefaultDisplay().getMetrics(dm);
        int screenWidth = dm.widthPixels;
        int screenHeight = dm.heightPixels;
        int dpi = dm.densityDpi;
        String text = "宽：" + screenWidth + "\n" +
                "高：" + screenHeight + "\n" +
                "DPI：" + dpi + "\n";
        tvInfo.setText(text);
    }

}
